#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

#define NOISY_TEST 0

void testEndTurn(){
	//int i, player;
	int seed = 11;
	int numPlayer = 2;
	int player;
	struct gameState state, state2;
	int cur;
	int k[10] = {adventurer, council_room, feast, gardens, mine,
					remodel, smithy, village, baron, great_hall};

	int r; // = initializeGame(numPlayer, k, seed, &state);

/* Analysis of endTurn()
 * endTurn only takes in the current game state.
 * endTurn discards the hand. Verify state->hand[][] is -1.  One is currentPlayer, the other is i?
 * state->handCount should be 0 for resetting handcount.
 * Verify state->outpostPlayed is 0
 * Verify state->phase is 0
 * Verify state->numActions is 1
 * Verify state->coins is 0
 * Verify state->numBuys is 1
 * Verify state->playedCardCount is 0
 * Verify state->handCount[state->whoseTurn] is 0
 * Verify that 5 cards are drawn?
 * Verify that coins were updated.
 *
 */

	for(player = 0; player < numPlayer; player++){
		memset(&state, 23, sizeof(struct gameState));
		r = initializeGame(numPlayer, k, seed, &state);
		memcpy(&state2, &state, sizeof(struct gameState)); //copy state of game before ending turn to verify turn was ended.
		state.whoseTurn = player; // making sure correct player is moving
#if (NOISY_TEST == 1)
      	printf("BEFORE: Player: %d, Hand Count: %d, Outpost Played: %d, Phase: %d, Actions: %d, Coins: %d, Buys: %d, PlayedCard: %d\n", player, state.handCount[player], state.outpostPlayed, state.phase, state.numActions, state.coins, state.numBuys, state.playedCardCount);
#endif
		cur = endTurn(&state);
#if (NOISY_TEST == 1)
      	printf("AFTER: Player: %d, Hand Count: %d, Outpost Played: %d, Phase: %d, Actions: %d, Coins: %d, Buys: %d, PlayedCard: %d\n", player, state.handCount[player], state.outpostPlayed, state.phase, state.numActions, state.coins, state.numBuys, state.playedCardCount);
#endif
		//assert(state.handCount[player] == 0);
		// handCount skipped due to drawCard
		assert(state.outpostPlayed == 0);
		assert(state.phase == 0);
		assert(state.numActions == 1);
		//assert(state.coins == updateCoins(state.whoseTurn, &state, 0));
		// coins skipped due to updateCoins
		assert(state.numBuys == 1);
		assert(state.playedCardCount == 0);
	}
	printf("Finishing testEndTurn()\n");
}

int main(){
	testEndTurn();
	return 0;
}
